package couponMetaService

import "fmt"

// RobStatus of message
type RobStatus int

const (
	RobOK RobStatus = iota
	RobInvalidParams
	RobTooBusy
	RobBusinessNotExist
	RobCouponNotExist
	RobStockNotCached
	RobCouponEmpty
	RobUnknownError
)

// RobResult RocketMQ Rob result
type RobResult struct {
	Status RobStatus
}

func NewRobResult() *RobResult {
	return &RobResult{Status: RobUnknownError}
}

// RobResult Rob message result to string(detail result)
func (result *RobResult) String() string {
	var msg string

	switch result.Status {
	case RobOK:
		msg = "Success"
	case RobInvalidParams:
		msg = "Invalid parameter(s)"
	case RobTooBusy:
		msg = "Too busy"
	case RobBusinessNotExist:
		msg = "Attempted business id does not exist"
	case RobCouponNotExist:
		msg = "Attempted coupon id does not exist"
	case RobStockNotCached:
		msg = "Stock is not loaded into cache"
	case RobCouponEmpty:
		msg = "Coupon has been emptied"
	case RobUnknownError:
		msg = "Unknown error"
	}

	return fmt.Sprintf("RobResult [RobStatus=%d] %s", result.Status, msg)
}
